package com.ybkj.daijia.serverUtils;

import java.io.FileNotFoundException;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author zhyu
 * @date 2019/4/29 14:44 desc:
 */

public class WebUtils {
    public static final Logger log = LoggerFactory.getLogger(WebUtils.class);

    public static String getBasePath(HttpServletRequest req) {
        try {
            return org.springframework.web.util.WebUtils
                .getRealPath(req.getSession().getServletContext(), "/");
        } catch (FileNotFoundException e) {
            if (log.isErrorEnabled()) {
                log.error("获取项目路径出错", e);
            }
        }
        return StringUtils.EMPTY;
    }

}
